package com.syg.servlet12_JDBC;

import java.sql.*;

/**
 * 单纯的java连接数据库
 */
public class _01_JDBC {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        String url = "";
        String userName = "";
        String password = "";
        Class.forName("");
        Connection con = DriverManager.getConnection(url,userName,password);
        Statement st = con.createStatement();
        /**
         * 1,查询
         */
        /*String sql = "SELECT  * FROM tbl_huishangyoucai";
        ResultSet rt = st.executeQuery(sql);
        while (rt.next()){
            System.out.println(rt.getString("huishang_id")+","+rt.getString("bankcode"));
        }*/

        /**
         * 2,增加
         */
        /*String sql = "insert INTO tbl_huishangyoucai(huishang_id,bankcode,custno) VALUES (1,3004,568976)";
        int lineNumber = st.executeUpdate(sql);
        if(lineNumber>0){
            System.out.println("添加成功");
        }*/

        /**
         * 3,修改
         */
        /*String sql = "update tbl_huishangyoucai set bankcode ='张三' where huishang_id = '1'";
        int lineNumber = st.executeUpdate(sql);
        if(lineNumber>0){
            System.out.println("修改成功");
        }*/

        /**
         * 4,删除
         */
        String sql = "delete from tbl_huishangyoucai where huishang_id = '1'";
        int lineNumber = st.executeUpdate(sql);
        if(lineNumber>0){
            System.out.println("删除成功");
        }
    }
}
